<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>FileDelete</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileDelete</h1>

<p>Deletes one or more files.</p>

<pre class="Syntax">FileDelete, FilePattern</pre>
<h3>Parameters</h3>
<dl>

  <dt>FilePattern</dt>
  <dd><p>The name of a single file or a wildcard pattern such as <code>C:\Temp\*.tmp</code>. <em>FilePattern</em> is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified.</p>
    <p>To remove an entire folder, along with all its sub-folders and files, use <a href="FileRemoveDir.htm">FileRemoveDir</a>.</p></dd>

</dl>

<h3>ErrorLevel</h3>
<p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to the number of files that failed to be deleted (if any) or 0 otherwise. Deleting a wildcard pattern such as <code>*.tmp</code> is considered a success even if it does not match any files; thus ErrorLevel is set to 0.</p>
<p>If files were found, <a href="../Variables.htm#LastError">A_LastError</a> is set to 0 (zero) or the result of the operating system's GetLastError() function immediately after the last failure. Otherwise A_LastError contains an error code that might indicate why no files were found.</p>

<h3>Remarks</h3>
<p>To delete a read-only file, first remove the read-only attribute. For example: <code><a href="FileSetAttrib.htm">FileSetAttrib</a>, -R, C:\My File.txt</code>.</p>
<h3>Related</h3>
<p><a href="FileRecycle.htm">FileRecycle</a>, <a href="FileRemoveDir.htm">FileRemoveDir</a>, <a href="FileCopy.htm">FileCopy</a>, <a href="FileMove.htm">FileMove</a></p>
<h3>Example</h3>
<pre class="NoIndent">FileDelete, C:\temp files\*.tmp</pre>

</body>
</html>
